package GradeTopN;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.Iterator;

//public class GradeTopNReducer extends Reducer  <Text,GradeTopNFlowBean,Text,GradeTopNFlowBean > {
//    @Override
//    protected void reduce(Text key, Iterable<GradeTopNFlowBean> values, Context context) throws IOException, InterruptedException {
//        for (GradeTopNFlowBean value : values){
//            context.write(key, value);
//        }
//    }

public class GradeTopNReducer extends Reducer <GradeTopNFlowBean, Text, GradeTopNFlowBean,Text> {
    @Override
    protected void reduce(GradeTopNFlowBean key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
//        for (GradeTopNFlowBean value : key){
//            context.write(value, values);
//        }
        Iterator<Text> i = values.iterator();

        while(i.hasNext()){
            Text value = i.next();
            context.write(key, value);
        }
    }

//    protected void reduce(KEYIN key, Iterable<VALUEIN> values, Reducer<KEYIN, VALUEIN, KEYOUT, VALUEOUT>.Context context) throws IOException, InterruptedException {
//        Iterator i$ = values.iterator();
//
//        while(i$.hasNext()) {
//            VALUEIN value = i$.next();
//            context.write(key, value);
//        }
//
//    }

}
